﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Iris.Engine;
using ModEngine;

namespace Iris.UnitTest
{
    public class UnitTest
    {
        public delegate void WriteLineHandler(string message, params object[] arg);
        public static WriteLineHandler WriteLine;

        public static void Assert(bool condition, string message, params object[] arg)
        {
            UnitTest.WriteLine((condition ? "[OK]" : "[KO]") + message, arg);
        }

        static void ExceptionRaised(Exception e, string message) {
            WriteLine(message);
            WriteLine(e.Message);

        }

        static public void Start()
        {
            WriteLine("Chargement des modules");

            SortCore.singleton.RaiseExceptionEvent += ExceptionRaised;
            SortCore.singleton.LoadModuleEvent += ModuleLoaded;
            SortCore.singleton.EndLoadModuleEvent += ModuleLoaded;
            

            SortCore.singleton.BeginLoadModule(@".\");
        }

        static void ModuleLoaded(IModule module)
        {
            WriteLine("\t - {0} {1}", module.getNameModule(), module.getVersion());
        }

        static void ModuleLoaded()
        {
            Assert(true, "Modules chargés");

            new ScenarioRunner().Run();
        }
    }
}
